// pages/person/person.js
let app = getApp()
Page({
    data: {
        user: null,
        userInfo: null,
        type: ''
    },

    editinfo() {
        let userId = this.data.user.userId
        wx.navigateTo({
            url: '/pages/personal/info/info?id=' + userId,
        })
    },
    cell(e) {
        if (!this.data.user) {
            this.login()
            return
        }

        let num = e.target.dataset.num
        if (num === '1') {
            wx.navigateTo({
                url: '/pages/personal/recipients/recipients',
            })
        } else if (num === '2') {
            wx.navigateTo({
                url: '/pages/personal/message/message',
            })
        } else if (num === '3') {
            wx.navigateTo({
                url: '/pages/personal/recipients/assisted/assisted?development=true',
            })
        } else if (num === '4') {
            wx.navigateTo({
                url: '/pages/finances/manage/manage',
            })
        } else if (num === '5') {
            wx.navigateTo({
                url: '/pages/personal/activity/activity?type=0',
            })
        } else if (num === '6') {
            wx.navigateTo({
                url: '/pages/finances/fundingList/fundingList?type=2',
            })
        } else if (num === '7') {
            wx.navigateTo({
                url: '/pages/finances/fundingList/fundingList?type=2',
            })
        } else if (num === '8') {
            wx.navigateTo({
                url: '/pages/personal/activity/activity?type=4',
            })
        }
    },
    login() {
        wx.navigateTo({
            url: '/pages/login/login',
        })
    },
    logout() {
        wx.clearStorage()
        wx.navigateTo({
            url: '/pages/login/login',
        })
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
        const user = wx.getStorageSync('user')
        this.setData({
            user
        })
        console.log(user);
        if (user.userType == '0') {
            this.setData({
                type: '受助人'
            })
        }
        if (user.userType == '1') {
            this.setData({
                type: '志愿者'
            })
        }
        if (user.userType == '2') {
            this.setData({
                type: '资助人'
            })
        }
        if (user.userType == '3') {
            this.setData({
                type: '老师'
            })
        }
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },



    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})